﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Beacon.Random;
using System.IO;

namespace Beacon.Test
{
    public class RandomTester
    {
        private const double Mu = 10;
        private const double Sigma = 0.8;

        public static void test()
        {
            NormalDistribution dist = new NormalDistribution(Mu, Sigma);
            List<double> data = new List<double>();
            FileStream file = File.OpenWrite("out.scv");
            StreamWriter sw = new StreamWriter(file); 
            for (int i = 0; i < 4000; i++)
            {
                double d = dist.NextDouble();
                Console.Write(string.Format("{0:0.####}",d));
                Console.Write("\t");
                if (i % 4 == 0)
                    Console.WriteLine();
                data.Add(d);

                sw.WriteLine(d.ToString());
            }
            sw.Close();
            file.Close();

            // that is not a good idea, 
            // maybe i should calculate the data's mean and sigma to see if it is match Mu and Sigma.
            if (Math.Abs(data.Average() - Mu) > 0.001)
            {
                Console.WriteLine();
                Console.WriteLine("====================");
                Console.WriteLine("average of data is " + data.Average().ToString());
                Console.WriteLine("tester think it is not a normal distribution for Mu "+Mu.ToString()+" and Sigma "+Sigma.ToString());
                Console.WriteLine("====================");
            }
        }
    }
}
